﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BTv2.Controls;
using BTv2.Model;

namespace BTv2.UserControls
{
    /// <summary>
    /// Interaction logic for MainWindowDefaultState.xaml
    /// </summary>
    public partial class MainWindowDefaultState : UserControl
    {
        private MainWindow _mw;

        public MainWindowDefaultState()
        {
            InitializeComponent();
        }

        public MainWindowDefaultState(MainWindow mw)
        {
            InitializeComponent();
            _mw = mw;
            Gtile.Click += _mw.ShowGraph;
            WTile.Click += _mw.ShowWheater;
         
           /// NotficationList.ItemsSource = new List<Notification>() { new Notification() { Timestamp = DateTime.Now, Content = "Bla bla", Type = "Crytical" }, new Notification() { Timestamp = DateTime.Now, Content = "Bla bla", Type = "Crytical" }, new Notification() { Timestamp = DateTime.Now, Content = "Bla bla", Type = "Crytical" }, new Notification() { Timestamp = DateTime.Now, Content = "Bla bla", Type = "Normal" } };
        }

        public async void AddNotification(Notification n)
        {
            NoticationContentControl.Content = new NotificationPresenter(n);
            await Task.Delay(5000);
            NoticationContentControl.Transition = "DownTransition";
            NoticationContentControl.Content = new BasicFiller();
            await Task.Delay(5000);
            NoticationContentControl.Transition = "UpTransition";
        }



        private void Open_Notifications(object sender, MouseButtonEventArgs e)
        {
            NotificationFlyout.IsOpen = !NotificationFlyout.IsOpen;
            if (NotificationFlyout.IsOpen) NotficationList.ItemsSource = NotificationsController.GetInstance().FetchLastFour();
        }

        private async void UserControl_Loaded_1(object sender, RoutedEventArgs e)
        {
            NotificationsController.GetInstance().SetNotificationDisplayer(this);
        ///await Task.Delay(2000);
       ///  AddNotification(new Notification() { Timestamp = DateTime.Now, Content = "Bla bla", Type = "Crytical" });
      ///   AddNotification(new Notification() { Timestamp = DateTime.Now, Content = "Bla bla", Type = "Crytical" });
       //  AddNotification(new Notification() { Timestamp = DateTime.Now, Content = "Bla bla", Type = "Crytical" });
        }

        private void NotificationFlyout_Loaded(object sender, RoutedEventArgs e)
        {
            NotficationList.ItemsSource = NotificationsController.GetInstance().FetchLastFour();
        }

    }
}

